<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>移动端更新</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<t:base type="bootstrap,layer,validform,bootstrap-form"></t:base>
<!-- 文件上传 -->
<link rel="stylesheet" type="text/css" href="plug-in/webuploader/webuploader.css"></link>
<script type="text/javascript" src="plug-in/webuploader/webuploader.min.js" ></script>
<style type="text/css">
#upBtn td{
	padding: 5px;
}
</style>
</head>
 <body style="overflow:hidden;overflow-y:auto;">
 <div class="container" style="width:100%;">
	<div class="panel-heading">
		<!-- 主键：${requestScope.weaApp.id}<br/> -->
		版本名称：${requestScope.weaApp.versionName}<br/>
		版本编码：${requestScope.weaApp.versionCode}<br/>
		描述：${requestScope.weaApp.desctition}<br/>
		发布时间：${requestScope.weaApp.addTime}<br/>
		文件名称：${requestScope.weaApp.fileName}<br/>
		文件大小：${requestScope.weaApp.fileSize}<br/>
		<%-- 平台${requestScope.weaApp.filePanel}<br/> --%>
		<%-- 版本编号：${requestScope.weaApp.versionNum}<br/> --%>
		<input type="hidden" value="${requestScope.weaApp.id}" id="weaAppId">
	</div>
	<div class="panel-body">
		<div id="uploader" class="wu-example">
	    	<!--用来存放文件信息-->
	    	<table class="table" id="fileBox">
	    		<thead>
	    			<tr>
		    			<td>
		    				文件名称
		    			</td>
		    			<td>
		    				文件大小
		    			</td>
		    			<td>
		    				上传状态
		    			</td>
	    			</tr>
	    		</thead>
	    		<tbody>
	    		</tbody>
	    	</table>
			<table id="upBtn">
				<tr>
					<td>
				        <div id="picker">选择文件</div>
					</td>
					<td valign="bottom">
				        <button id="ctlBtn" class="btn btn-default">开始上传</button>
					</td>
				</tr>
			</table>
		</div>
		<div style="position: absolute;right: 20px;bottom: 20px;">
	        <button id="okBtn" class="btn btn-primary">完成</button>
		</div>
	</div>
 </div>
<script type="text/javascript">
	var uploader = WebUploader.create({
		server: "weaAppController.do?doUpload",
	    formData:{
	    	weaAppId:document.getElementById("weaAppId").value
	    },
	    pick: '#picker',
	    fileVal:'appFile',
	    fileNumLimit:1,
	    swf: '/plug-in/webuploader/Uploader.swf',
	    resize: false,
	    duplicate: false,
	    auto: false,
	    accept:{
			title:'请选择apk和wgt文件',
			extensions:'apk,wgt,zip,rar'
	    }
	});
	document.getElementById("ctlBtn").onclick=function(){
		uploader.upload();
	}
	uploader.on( 'fileQueued', function( file ) {
		var fileLine="<tr id='f_"+file.id+"'>"
						+"<td>"+file.name+"</td>"
						+"<td>"+file.size+"</td>"
						+"<td>待上传...</td>"
					+"</tr>";
		$("#fileBox tbody").append(fileLine);
	}); 
	uploader.on( 'uploadProgress', function( file, percentage ) {
	    var fLine = $( '#f_'+file.id );
	    $(fLine.children()[2]).html("上传进度：【"+percentage*100+"%】");
	});
	document.getElementById("okBtn").onclick=function(){
		var win = frameElement.api.opener;
		frameElement.api.close();
		win.reloadTable();
	}
	uploader.on( 'uploadSuccess', function(file,response) {
		if(response.code == 1){
			var win = frameElement.api.opener;
			win.tip(response.msg);
		}
	});
	uploader.on( 'uploadError', function(file,reason) {
		var win = frameElement.api.opener;
		win.tip(reason);
	});
</script>
</body>
</html>